import { addNameSpace } from './util'

const NAME_SPACE = 'LOGIN'

const addPrefix = addNameSpace(NAME_SPACE)

// 获取图片验证码
export const GET_VALIDATE_PICTURE = addPrefix('GET_VALIDATE_PICTURE')

// 获取图片验证码失败
export const GET_VALIDATE_PICTURE_FAIL = addPrefix('GET_VALIDATE_PICTURE_FAIL')

// 设置图片验证码
export const SET_VALIDATE_PICTURE = addPrefix('SET_VALIDATE_PICTURE')

// 输入用户名
export const SET_ACCOUNT = addPrefix('SET_ACCOUNT')

// 输入密码
export const SET_PASS_WORD = addPrefix('SET_PASS_WORD')

// 输入验证码
export const SET_VALIDATE_CODE = addPrefix('SET_VALIDATE_CODE')

// 登录
export const LOGIN = addPrefix('LOGIN')

// 登录成功
export const LOGIN_SUCCESS = addPrefix('LOGIN_SUCCESS')

// 登录失败
export const LOGIN_FAIL = addPrefix('LOGIN_FAIL')

export const getValidatePicture = () => ({ type: GET_VALIDATE_PICTURE })

export const getValidatePictureFail = () => ({ type: GET_VALIDATE_PICTURE_FAIL })

export const setValidatePicture = (validatePictureData) => ({ type: SET_VALIDATE_PICTURE, validatePictureData })

export const setAccount = (account) => ({ type: SET_ACCOUNT, account })

export const setPassWord = (passWord) => ({ type: SET_PASS_WORD, passWord })

export const setValidateCode = (validateCode) => ({ type: SET_VALIDATE_CODE, validateCode })

export const login = () => ({ type: LOGIN })

export const loginSuccess = () => ({ type: LOGIN_SUCCESS })

export const loginFail = () => ({ type: LOGIN_FAIL })

export default {
  getValidatePicture,
  getValidatePictureFail,
  setValidatePicture,
  setAccount,
  setPassWord,
  setValidateCode,
  login,
  loginSuccess,
  loginFail,
}